home *** CD-ROM | disk | FTP | other *** search
/ Flash MX Savvy / FlashMX Savvy.iso / pc / WIN / UltraDev / UltraDev_Trial.exe / Disk1 / data1.cab / Configuration_En / Commands / Date.js < prev    next >
Encoding:
JavaScript  |  2000-12-11  |  18.9 KB  |  655 lines

  1.  
  2. //
  3. // Copyright 1999 Macromedia, Inc. All rights reserved. 
  4. //
  5. // ----------------------------------------------------
  6. //
  7. // Date.js
  8. //
  9. //This object inserts the current date and optionally time
  10. //and day at the current insertion point. An Update Automatically
  11. //On Save Option will update the date when the document is saved.
  12. //
  13. //
  14. //Localization Note:
  15. //Read the comments in the initGlobals function for instructions
  16. //on controlling the order of the date formats in the Date Format list,
  17. //as well as specifying that certain date formats should not appear
  18. //in a localized language.
  19.  
  20.  
  21.  
  22. //*********************GLOBAL VARIABLES***********************
  23.  
  24. //see initGlobals for info on global vars
  25.  
  26. var helpDoc = MM.HELP_objDate;
  27.  
  28. //global arrays
  29. var GarrDateFormats; 
  30. var GarrDayFormats;
  31. var GarrTimeFormats;
  32.  
  33. //form element objects
  34. var GlistDateFormats;
  35. var GselDayFormats;
  36. var GselTimeFormats;
  37. var GcbUpdate;
  38.  
  39. //global strings needed for accessor functions
  40. var GstrFullDate;
  41. var GstrHTMLFullDate;
  42. var GstrDateID;
  43.  
  44. function initGlobals(){
  45.  
  46.     //The GarrDateFormats array controls the order the date formats are shown in the UI
  47.     //The list of formats is in Date.htm
  48.     GarrDateFormats = LIST_DateFormats;
  49.  
  50.     //The GarrDateFormats array controls the order the day formats are shown in the UI
  51.     //The list of formats is in Date.htm
  52.     GarrDayFormats  =  LIST_DayFormats;
  53.  
  54.     //The GarrTimeFormats array controls the order of the time formats.
  55.     //The list of formats is in Date.htm
  56.     GarrTimeFormats =  LIST_TimeFormats;
  57.  
  58.  
  59.  
  60.    //-----------------------------------------------------------------------------
  61.    
  62.    //initialize global form elements
  63.    theForm = document.forms[0]; 
  64.    GlistDateFormats = theForm.DateFormats;
  65.    GselDayFormats   = theForm.DayFormats;
  66.    GselTimeFormats  = theForm.TimeFormats;
  67.    GcbUpdate        = theForm.Update;
  68. }
  69.  
  70. function charToEntity(thechar,charCode)
  71. {
  72.     switch(thechar) {
  73.         case '\x80' :         return "€";
  74.         case '\xA1' :         return "¡";
  75.         case '\xA2' :         return "¢";
  76.         case '\xA3' :         return "£";
  77.         case '\xA4' :         return "¤";
  78.         case '\xA5' :         return "¥";
  79.         case '\xA6' :         return "¦";
  80.         case '\xA7' :         return "§";
  81.         case '\xA8' :         return "¨";
  82.         case '\xA9' :         return "©";
  83.         case '\xAA' :         return "ª";
  84.         case '\xAB' :         return "«";
  85.         case '\xAC' :         return "¬";
  86.         case '\xAD' :         return "­";
  87.         case '\xAE' :         return "®";
  88.         case '\xAF' :         return "¯";
  89.         case '\xB0' :         return "°";
  90.         case '\xB1' :         return "±";
  91.         case '\xB2' :         return "²";
  92.         case '\xB3' :         return "³";
  93.         case '\xB4' :         return "´";
  94.         case '\xB5' :         return "µ";
  95.         case '\xB6' :         return "¶";
  96.         case '\xB7' :         return "·";
  97.         case '\xB8' :         return "¸";
  98.         case '\xB9' :         return "¹";
  99.         case '\xBA' :         return "º";
  100.         case '\xBB' :         return "»";
  101.         case '\xBC' :         return "¼";
  102.         case '\xBD' :         return "½";
  103.         case '\xBE' :         return "¾";
  104.         case '\xBF' :         return "¿";
  105.         case '\xD7' :         return "×";
  106.         case '\xF7' :         return "÷";
  107.         case '\xC6' :         return "Æ";
  108.         case '\xC1' :         return "Á";
  109.         case '\xC2' :         return "Â";
  110.         case '\xC0' :         return "À";
  111.         case '\xC5' :         return "Å";
  112.         case '\xC3' :         return "Ã";
  113.         case '\xC4' :         return "Ä";
  114.         case '\xC7' :         return "Ç";
  115.         case '\xD0' :         return "Ð";
  116.         case '\xC9' :         return "É";
  117.         case '\xCA' :         return "Ê";
  118.         case '\xC8' :         return "È";
  119.         case '\xCB' :         return "Ë";
  120.         case '\xCD' :         return "Í";
  121.         case '\xCE' :         return "Î";
  122.         case '\xCC' :         return "Ì";
  123.         case '\xCF' :         return "Ï";
  124.         case '\xD1' :         return "Ñ";
  125.         case '\xD3' :         return "Ó";
  126.         case '\xD4' :         return "Ô";
  127.         case '\xD2' :         return "Ò";
  128.         case '\xD8' :         return "Ø";
  129.         case '\xD5' :         return "Õ";
  130.         case '\xD6' :         return "Ö";
  131.         case '\xDE' :         return "Þ";
  132.         case '\xDA' :         return "Ú";
  133.         case '\xDB' :         return "Û";
  134.         case '\xD9' :         return "Ù";
  135.         case '\xDC' :         return "Ü";
  136.         case '\xDD' :         return "Ý";
  137.         case '\xE1' :         return "á";
  138.         case '\xE2' :         return "â";
  139.         case '\xE6' :         return "æ";
  140.         case '\xE0' :         return "à";
  141.         case '\xE5' :         return "å";
  142.         case '\xE3' :         return "ã";
  143.         case '\xE4' :         return "ä";
  144.         case '\xE7' :         return "ç";
  145.         case '\xE9' :         return "é";
  146.         case '\xEA' :         return "ê";
  147.         case '\xE8' :         return "è";
  148.         case '\xF0' :         return "ð";
  149.         case '\xEB' :         return "ë";
  150.         case '\xED' :         return "í";
  151.         case '\xEE' :         return "î";
  152.         case '\xEC' :         return "ì";
  153.         case '\xEF' :         return "ï";
  154.         case '\xF1' :         return "ñ";
  155.         case '\xF3' :         return "ó";
  156.         case '\xF4' :         return "ô";
  157.         case '\xF2' :         return "ò";
  158.         case '\xF8' :         return "ø";
  159.         case '\xF5' :         return "õ";
  160.         case '\xF6' :         return "ö";
  161.         case '\xDF' :         return "ß";
  162.         case '\xFE' :         return "þ";
  163.         case '\xFA' :         return "ú";
  164.         case '\xFB' :         return "û";
  165.         case '\xF9' :         return "ù";
  166.         case '\xFC' :         return "ü";
  167.         case '\xFD' :         return "ý";
  168.         case '\xFF' :         return "ÿ";
  169.  
  170.     }
  171.     if (charCode > 128)
  172.         return('&#' + parseInt(charCode) + ';');
  173.     else
  174.         return(thechar);
  175. }
  176.  
  177.  
  178. function entityNameEncode(string)
  179. {
  180.     latin1Str = dreamweaver.nativeToLatin1(string);
  181.     returnString = new String();
  182.     for (i=0;i<latin1Str.length;i++) {
  183.         returnString += charToEntity(latin1Str.charAt(i),latin1Str.charCodeAt(i));
  184.     }
  185.     return(returnString);
  186. }
  187.  
  188. //*********************** API ***********************
  189.  
  190. function isDOMRequired() { 
  191.     // Return false, indicating that this command is available in code view.
  192.     return false;
  193. }
  194.  
  195. //function: commandButtons
  196. //description: generic API function, returns string to be inserted at IP
  197.  
  198. function commandButtons(){
  199.    return new Array(BTN_OK,         "setDateStr();window.close()",
  200.                     BTN_Cancel,     "window.close()",
  201.                     BTN_Help,       "displayHelp()"    );
  202.  
  203.  
  204. }
  205.  
  206. //***********************ACCESSOR FUNCTIONS***********************
  207.  
  208. function getDateStr(){
  209.    return GstrFullDate;
  210. }
  211.  
  212. function getDateID(){
  213.    return GstrDateID;
  214. }
  215.  
  216. function getHTMLDateStr(){
  217.    return GstrHTMLFullDate;
  218. }
  219.  
  220. //***********************LOCAL FUNCTIONS***********************
  221.  
  222. //function: setDateStr
  223. //description: called from OK button of dialog,
  224. //sets the global GstrFullDate variable
  225.  
  226. function setDateStr(){
  227.     var dateStr = "";
  228.     var dateStrHTML = "";
  229.     var dateID = "";
  230.     var now = new Date();
  231.     
  232.     var dayFormat  = getSelectedOptionAttr(GselDayFormats,"value");
  233.     var dateFormat = getSelectedOptionAttr(GlistDateFormats,"value");
  234.     var timeFormat = getSelectedOptionAttr(GselTimeFormats,"value");        
  235.     
  236.     //create the date that is inserted
  237.     //if selected a Japanese date format in J version of Dreamweaver, concatenate in order of
  238.     //date, day, time
  239.     if (dateFormat.indexOf("Japan") == 0 && (dreamweaver.appVersion && dreamweaver.appVersion.indexOf('ja') != -1)) {
  240.         dateStr += createDateStr(now,dateFormat,true);
  241.         dateStr += " " + createDayStr(now,dayFormat,false,true);
  242.         dateStr += createTimeStr(now,timeFormat);
  243.         dateStrHTML += createDateStr(now,dateFormat,true);
  244.         dateStrHTML += " " + createDayStr(now,dayFormat,false,true);
  245.         dateStrHTML += createTimeStr(now,timeFormat);
  246.     }
  247.     else
  248.     {
  249.         dateStr += createDayStr(now,dayFormat,false,true);
  250.         dateStr += createDateStr(now,dateFormat,true);
  251.         dateStr += createTimeStr(now,timeFormat);
  252.         dateStrHTML += createDayStr(now,dayFormat,false,false);
  253.         dateStrHTML += createDateStr(now,dateFormat,false);
  254.         dateStrHTML += createTimeStr(now,timeFormat);
  255.     }
  256.     
  257.     //dateID is inserted into the format attribute of the lock
  258.     //and also placed in the opening comment
  259.     dateID = createDateID(dayFormat,dateFormat,timeFormat);
  260.     
  261.     //if Update Automatically On Save is visible and checked,
  262.     //add locks around the date
  263.     if (GcbUpdate!=null && GcbUpdate.checked){
  264.        dateStr = addLockMarkup(dateStr,dateID);  
  265.        dateStrHTML = addLockMarkup(dateStrHTML,dateID);   
  266.     }
  267.     
  268.     //assign to global variables accessed by accessor functions
  269.     GstrFullDate = dateStr;
  270.     GstrHTMLFullDate = dateStrHTML;
  271.     GstrDateID = dateID;  
  272. }
  273.  
  274.  
  275.  
  276. //function: addLockMarkup
  277. //description: adds correct lock markup to the date that is 
  278. //inserted
  279.  
  280. function  addLockMarkup(dateStr,dateID){
  281.  
  282.    var openBracket = "%3C";
  283.    var closeBracket = "%3E";
  284.    var quote = "%22";
  285.  
  286.    var openComment = openBracket + '!-- #BeginDate ' +
  287.                      'format:' + dateID + ' --' + closeBracket;
  288.    var closeComment = openBracket + '!-- #EndDate --' + closeBracket;
  289.    var origAttr = openComment + dateStr + closeComment;
  290.    
  291.    var openLock = '<MM:BeginLock type="mmdate" format="' + dateID + 
  292.                   '" orig="' + origAttr + '">';
  293.    var closeLock =  '<MM:EndLock>';
  294.    
  295.    return openLock +  dateStr + closeLock;
  296. }
  297.  
  298.  
  299.  
  300. //function: initializeUI
  301. //description: initializes the global variables, and populates
  302. //the UI with date format examples.
  303.  
  304. function initializeUI(){
  305.    //return if already initialized
  306.    //(this happens if command is called from PI)
  307.    if (GarrDateFormats){
  308.       GlistDateFormats.focus();
  309.       return;
  310.    }
  311.       
  312.    initGlobals(); //initialize global variables
  313.    populateUI();  //populate UI
  314. }
  315.  
  316.  
  317.  
  318. //function: populateUI
  319. //description: populate the UI with date format examples
  320.  
  321. function populateUI(){
  322.    var dateFormatsArr = GarrDateFormats;  //shorter names easier to work with
  323.    var dayFormatsArr  = GarrDayFormats;
  324.    var timeFormatsArr = GarrTimeFormats;
  325.    
  326.    var nDateFormats = dateFormatsArr.length;
  327.    var nDayFormats  = dayFormatsArr.length;
  328.    var nTimeFormats = timeFormatsArr.length;
  329.    
  330.    var dateObj = new Date("74","2","7","22","18");  //examples are for March 7, 1974
  331.    var dateStr = "",timeStr="",dayStr=""; 
  332.    
  333.     //populate day format list in UI
  334.    //the first line creates an array of formatted dayes
  335.    //(the createDayStr function is overloaded to return one item
  336.    //or an array, therefore, unfortunately the function name isn't 
  337.    //always entirely accurate)
  338.    dayFormatsArr = createDayStr(dateObj,dayFormatsArr,true,true);
  339.    var counter = 0;
  340.    for (i in dayFormatsArr){
  341.       if (!dayFormatsArr[i].prototype){ 
  342.          // Val 13-aug-99 use temporary for speedier UI loading
  343.          var curr = new Option(dayFormatsArr[i]);
  344.          curr.value = i;
  345.          GselDayFormats.options[ counter++ ] = curr;
  346.       }
  347.    }
  348.    
  349.    //populate date format list in UI
  350.    //the first line creates an array of formatted dates
  351.    //(the createDateStr function is overloaded to return one item
  352.    //or an array, therefore, unfortunately, the function name isn't 
  353.    ///always entirely accurate)
  354.    dateFormatsArr  = createDateStr(dateObj,dateFormatsArr,true);
  355.    counter = 0;
  356.    for (i in dateFormatsArr){
  357.       if (!dateFormatsArr[i].prototype){
  358.          // Val 13-aug-99: use a temporary to make initialization faster,
  359.          // and only assign to the formats array once.
  360.            var currObj = new Option(dateFormatsArr[i]);
  361.          currObj.value = i;
  362.          GlistDateFormats.options[ counter++ ] = currObj;
  363.       }
  364.    }
  365.    
  366.    //populate time format list
  367.    for (i=0;i<nTimeFormats;i++){
  368.       timeStr = createTimeStr(dateObj, timeFormatsArr[i], true);
  369.       GselTimeFormats.options[ i ] = new Option(timeStr);
  370.       GselTimeFormats.options[ i ].value = timeFormatsArr[i];
  371.    }
  372.   
  373.    
  374.    //select first option of each menu
  375.    GselDayFormats.selectedIndex = 0;
  376.    GlistDateFormats.selectedIndex = 0;
  377.    GselTimeFormats.selectedIndex = 0;
  378.    
  379.    //put focus in date formats field
  380.    GlistDateFormats.focus();
  381. }
  382.  
  383.  
  384.  
  385. //function: lead
  386. //description: given a one or two digit number,
  387. //adds a leading 0 if a 1 digit number
  388.  
  389. function lead(num){
  390.    if (num.toString().length == "1")
  391.       return "0" + num;
  392.    return ( num );
  393. }
  394.  
  395.  
  396. //function: createDateStr
  397. //description: given a date obj and a date format or formats
  398. //returns an array with the correctly formatted date strings
  399. //overloaded: dateFormat can be one item or an array
  400. //if it is one item, returns one item
  401. //if it is an array, returns an array
  402.  
  403. function createDateStr(dateObj,dateFormat,highAscii){
  404.    var date = dateObj.getDate();
  405.    var day = dateObj.getDay();
  406.    var month = dateObj.getMonth();
  407.    var year = dateObj.getYear();
  408.    var abbrYear = (year<100)? year : year.toString().substring(1);
  409.    var fullYear = (year<100)? "19" + year : year + 1900;
  410.    
  411.    var retVal; //return value;
  412.    
  413.    var abbrMonth;
  414.    var fullMonth;
  415.    if (highAscii) {
  416.        abbrMonth = ARR_AbbrMonths[ month ];
  417.        fullMonth = ARR_FullMonths[ month++ ];
  418.    } else {
  419.          abbrMonth = entityNameEncode(ARR_AbbrMonths[ month ]);
  420.        fullMonth = entityNameEncode(ARR_FullMonths[ month++ ]); 
  421.    }
  422.    //the dateFormat argument is overloaded so that it
  423.    //can be either a string or an array. Handle accordingly.
  424.    if (typeof dateFormat == "string"){
  425.       retVal = createCorrectDateFormat(dateFormat,date,day,month,abbrMonth,fullMonth,
  426.                                        year,abbrYear,fullYear);
  427.    } else { //dateFormat is an array
  428.         retVal = new Array();
  429.         dateFormats = dateFormat; //rename
  430.         var nFormats = dateFormats.length;
  431.  
  432.         
  433.         for (var i=0;i<nFormats;i++){
  434.            retVal[dateFormats[i]] = createCorrectDateFormat(dateFormat[i],date,day,month,abbrMonth,
  435.                                                fullMonth,year,abbrYear,fullYear);
  436.             
  437.         }
  438.    }    
  439.    
  440.    return retVal;
  441. }
  442.  
  443.  
  444. //function: createCorrectDateFormat
  445. //description: returns a correclty formatted date string
  446.  
  447. function createCorrectDateFormat(dateFormat,date,day,month,abbrMonth,fullMonth,
  448.                                  year,abbrYear,fullYear,time){
  449.  
  450.     var dateStr = "";
  451.    
  452.     switch (dateFormat){
  453.     
  454.        case "American1":  // Thursday, March 7, 1974
  455.           dateStr += fullMonth + " " + date + ", " + fullYear;
  456.           break;
  457.           
  458.        case "American2":  // 3/7/74
  459.           dateStr += month + "/" + date + "/" + abbrYear;
  460.           break;
  461.           
  462.        case "American3":  // 03/07/1974
  463.           dateStr += lead(month) + "/" + lead(date) + "/" + fullYear;
  464.           break;
  465.  
  466.        case "ISO8601":  // 1974-03-07
  467.           dateStr += fullYear + "-" + lead(month) + "-" + lead(date);
  468.           break;
  469.           
  470.        case "English1":  // 7-mar-74
  471.           dateStr += date + "-" + abbrMonth + "-" + abbrYear;
  472.           break;
  473.       
  474.        case "English2":  // 07-Mar-1974
  475.           abbrMonth = abbrMonth.charAt(0).toUpperCase()+abbrMonth.substring(1);
  476.           dateStr += lead(date) + "-" + abbrMonth + "-" + fullYear;
  477.           break;
  478.           
  479.        case "Spanish1":  // 7/3/74 
  480.           dateStr += date + "/" + month + "/" + abbrYear;
  481.           break;
  482.           
  483.        case "French1":  //  7/03/74
  484.           dateStr += date + "/" + lead(month) + "/" + abbrYear;
  485.           break;
  486.           
  487.        case "Italian1":  // 7-03-1974
  488.           dateStr += date + "-" + lead(month) + "-" + fullYear;
  489.           break;
  490.           
  491.        case "Brazilian1":  // 07.03.74
  492.           dateStr += lead(date) + "." + lead(month) + "." + abbrYear;
  493.           break;
  494.           
  495.        case "German1":  // 07.03.1974
  496.           dateStr += lead(date) + "." + lead(month) + "." + fullYear;
  497.           break;
  498.           
  499.        case "Japanese1":  // 74/03/07
  500.           dateStr += abbrYear + "/" + lead(month) + "/" + lead(date) ;
  501.           break;
  502.  
  503.        case "Japanese2":  // 1974îN3åé7ì˙
  504.           dateStr += fullYear + "îN" + fullMonth + date + "ì˙";
  505.           break;
  506.  
  507.        case "Japanese3":  // 1974îN03åé07ì˙
  508.           dateStr += fullYear + "îN" + lead(month) + "åé" + lead(date) + "ì˙";
  509.           break;
  510.                     
  511.        case "Swedish1":  //  7 March, 1974
  512.           dateStr +=  date + " " + fullMonth + ", " + fullYear;
  513.           break;
  514.           
  515.        default:
  516.           break;
  517.    }
  518.    
  519.    return dateStr;
  520.  
  521. }
  522.  
  523.  
  524.  
  525. //function: createDayStr
  526. //description: see createDateStr notes. Except of course this function
  527. //returns a correctly formatted day (or days) instead of a date
  528.  
  529. function createDayStr(dateObj,dayFormat,bPreview,highAscii){
  530.    var    day = dateObj.getDay();
  531.    var    WestFullDay = ARR_WestFullDays[day];
  532.    var    WestAbbrDay = ARR_WestAbbrDays[day];
  533.    var    fullDay;
  534.    var    abbrDay;
  535.  
  536.    if (highAscii) {
  537.      fullDay = ARR_FullDays[day];
  538.      abbrDay = ARR_AbbrDays[day];
  539.    } else {
  540.       fullDay = entityNameEncode(ARR_FullDays[day]);
  541.       abbrDay = entityNameEncode(ARR_AbbrDays[day]);
  542.    }
  543.  
  544.    if (typeof dayFormat == "string"){
  545.       retVal = createCorrectDayFormat(dayFormat,fullDay,abbrDay,WestFullDay,WestAbbrDay,bPreview);
  546.    } else { //dayFormat is an array
  547.         retVal = new Array();
  548.         dayFormats = dayFormat; //rename for clarity
  549.         var nFormats = dayFormats.length;
  550.  
  551.         for (var i=0;i<nFormats;i++){
  552.            retVal[dayFormats[i]] = createCorrectDayFormat(dayFormat[i],fullDay,abbrDay,WestFullDay,WestAbbrDay,bPreview);
  553.         }
  554.    }    
  555.    return retVal;
  556. }
  557.  
  558.  
  559.  
  560. //function: createCorrectDayFormat
  561. //description: returns the correctly formatted day format
  562.  
  563. function createCorrectDayFormat(dayFormat,fullDay,abbrDay,WestFullDay,WestAbbrDay,bPreview){
  564.  
  565.    var dayStr = "";
  566.  
  567.    switch (dayFormat){
  568.    
  569.       case "NoDay":
  570.          if (bPreview)
  571.             dayStr = "[" + OPTION_NoDay + "]";
  572.          break;
  573.           
  574.       case "FullDayComma":
  575.          dayStr = CHAR_PreDay + fullDay + CHAR_PostDay;
  576.          break;
  577.          
  578.       case "FullDay":
  579.          dayStr = fullDay + " ";
  580.          break;
  581.          
  582.       case "AbbrDayComma":
  583.          dayStr = CHAR_PreDay + abbrDay + CHAR_PostDay;
  584.          break;
  585.          
  586.       case "AbbrDay":
  587.          dayStr = abbrDay + " ";
  588.          break;
  589.          
  590.       case "LowAbbrDayComma":
  591.          dayStr = abbrDay.toLowerCase() + ", ";
  592.          break;
  593.          
  594.       case "LowAbbrDay":
  595.          dayStr = abbrDay.toLowerCase() + " ";
  596.          break;
  597.  
  598.       case "WestFullDayComma":
  599.          dayStr = WestFullDay + ", ";
  600.          break;
  601.     
  602.       case "WestAbbrDayComma":
  603.          dayStr = WestAbbrDay + ", ";
  604.          break;
  605.          
  606.       default:
  607.          break;
  608.    
  609.    }
  610.  
  611.    return dayStr;
  612.  
  613. }
  614.  
  615.  
  616.  
  617. //function: createTimeStr
  618. //description: given a dateObj and a time format,
  619. //returns the correctly formatted time string
  620. //The time format argument is "a" for AM/PM,
  621. //"m" for military time, and "" for no time
  622.  
  623. function createTimeStr(dateObj,timeFormat,bPreview){
  624.    var hours = dateObj.getHours();
  625.    var minutes = lead(dateObj.getMinutes());
  626.    var timeStr = "";  //return value
  627.    
  628.    switch (timeFormat){
  629.       case "NoTime":
  630.          if (bPreview)
  631.             timeStr = "[" + OPTION_NoTime + "]";
  632.          break;
  633.          
  634.        case "AMPMTime":
  635.              timeStr += (hours>=12) ? ((hours-12==0)?hours:hours-12) + ":" + minutes + " " + PM :
  636.                   hours + ":" + minutes + " " + AM;
  637.            timeStr = " " + timeStr;
  638.            break;
  639.           
  640.       case "MilitaryTime":
  641.          timeStr += " " + hours + ":" + minutes;
  642.            timeStr = " " + timeStr;
  643.            break;
  644.          
  645.       default:
  646.          break;
  647.    }
  648.          
  649.    return timeStr;
  650. }
  651.  
  652.  
  653.  
  654.  
  655.